var express = require("express");
var app = express();
var config = require("./server/config/config.js");
var mongoose = require("mongoose");
var bodyParser = require("body-parser");
var db = mongoose.connection;
var path = require("path");
//博主信息
var blogProfiles = require("./server/controllers/admin/webConfig.js");
//文章
var article = require("./server/controllers/admin/article.js");
//栏目
var column = require("./server/controllers/admin/column.js");
//banner
var banner = require("./server/controllers/admin/banner.js");
//链接数据库
mongoose.connect(config.host+"/"+config.db);
db.on("error" , function(error){
	console.log("数据库链接出错"+error);
});
db.on("open" , function(){
	console.log("数据库链接成功");
});
//设置post请求大小
app.use(bodyParser.json({ "limit":"10000kb"}));
//解析json中间件
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
//静态资源设置
app.use(express.static(path.join(__dirname, "./src")));
//路由
app.use("/" , blogProfiles , article , column , banner);
//端口
app.listen(config.port , function(){
	console.log("服务启动成功");
});
